package com.ssyx.cart.controller;

import com.ssyx.cart.service.CartInfoService;
import com.ssyx.common.auth.AuthContextHolder;
import com.ssyx.common.result.Result;
import com.ssyx.model.order.CartInfo;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName:CartInnerController
 * Description:
 *
 * @Author kay
 * @Create 2024/5/22 9:28
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/cart")
public class CartInnerController {

    @Autowired
    private CartInfoService cartInfoService;

    //根据用户id得到,购物车中被选中的商品项列表
    @GetMapping("inner/getCartCheckedList/{userId}")
    public List<CartInfo> getCartCheckedList(@PathVariable("userId") Long userId) {
        List<CartInfo> CartInfoList = cartInfoService.getCartCheckedList(userId);
        return CartInfoList;
    }

    //删除购物车中,被选中的商品
    @DeleteMapping("inner/removeCartChecked")
    public Boolean removeCartChecked(){
        return cartInfoService.removeCartChecked();
    }

    //批量删除购物车商品
    @PostMapping("inner/batchDeleteCart/{userId}")
    public Boolean batchDeleteCart(@RequestBody List<Long> skuIdList,
                                   @PathVariable Long userId){
        cartInfoService.batchDeleteCart(skuIdList, userId);
        return true;
    }
}
